<?php

//require_once ('deploy/lib/class.dbModel.php');

class db_competenties extends dbModel
{
	protected $sSource = "competenties";
	
	//get modules (by student_code, class_code or both)
	function listCompetenties($module_code = false, $student_code = false)
	{
		
		//if there is no student code given
		if(!$module_code && !$student_code) {
			$sSql = "SELECT 
						id, competentie_naam, competentie_omschrijving
					FROM 
						competenties";
			
			$this->trashcan();
			
			//fake de dbModel functie
			$this->run_query($sSql);
			$this->oBench->start_mark();
			$this->iTotal = mysql_num_rows($this->rResult);
			$this->oBench->add_mark('counted rows');
			return $this->iTotal > 0;
			
		//if there is no class code given
		} else if($module_code){
			
			//sql query
			$sSql = "SELECT 
						c.id, competentie_naam, competentie_omschrijving
					FROM 
						competenties c
					INNER JOIN
						connect_module_competentie cmc 
					ON 
						(cmc.competentie_id = c.id)
					WHERE cmc.module_id = '$module_code'";
			
			$this->trashcan();
			
			//fake de dbModel functie
			$this->run_query($sSql);
			$this->oBench->start_mark();
			$this->iTotal = mysql_num_rows($this->rResult);
			$this->oBench->add_mark('counted rows');
			return $this->iTotal > 0;
		} else if($module_code && student_code){
			
			//sql query
			$sSql = "SELECT 
						criteria_id, cirteria_name
					FROM 
						criterias
					INNER JOIN
						connect_module_criteria cmc 
					ON 
						(cmc.module_code = '$module_code')";
			
			$this->trashcan();
			
			//fake de dbModel functie
			$this->run_query($sSql);
			$this->oBench->start_mark();
			$this->iTotal = mysql_num_rows($this->rResult);
			$this->oBench->add_mark('counted rows');
			return $this->iTotal > 0;
		} 
	}
}

?>
